<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$gametype = intval(getvar("gametype"));
$gType = chkGametype($gametype);
switch ($gType)
{
    case 0 :
        $ui = new UI();
        if ($curruser['prev_id'] == 0)
        {
            include( "admin_menu.php" );
        }
        else
        {
            include( "admin_menu1.php" );
        }
        break;
    default :
        include_once( "class_3d/CheckMode_3d.php" );
        $chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
        $chk->checkShow3dPage();
        unset($chk);
        $ui = new UI_3D();
        $jslink = "<script language=\"JScript.Encode\" src=\"site.js\"></script>" . ( "<script language=\"VBScript.Encode\" src=\"site.vbs\"></script>" );
        $ui->set("jslink", $jslink);
        $ui->header();
        if ($curruser['prev_id'] == 0)
        {
            include( "admin_menu_3d.php" );
        }
        else
        {
            include( "admin_menu1_3d.php" );
        }
        break;
}
$tpl = new Template2();
$tpl->load(array("main" => "chgpwd.htm"));
if (ispost())
{
    $newpass = getvar("newpass");
    if (5 < strlen($newpass))
    {
        getdb("update k_user set pass='" . md5($newpass) . "' where id=" . $curruser['id']);
        getdb("delete from k_sessions where uid=" . $curruser['id']);
        header("refresh: 8; url=op.php?op=core&fp=logout;");
        $msg = "<p>更改密码成功！</p><p>你必须用新密码重新登入</p>";
        $msg .= "<script language=\"JavaScript\">\r\n    function chgURl(){\r\n      window.top.location.href = 'op.php?op=core&fp=logout';\r\n    }\r\n    setTimeout(function(){chgURl();},4000);\r\n    </script>";
        $ui->showErrorPage($msg);
        exit();
    }
}
$tpl->set("action", "op.php?op=admin&fp=chgpwd&gametype={$gametype}");
$tpl->set("sysname", $curruser['account']);
$tpl->set("gametype", $gametype);
$tpl->show("main");
?>